function showpage(div,url,total,pagesize,curpage,pagecount){
	if(total==0){ 
		return false;
	}
	var pagediv = '<span>當前<strong>' + curpage + '</strong>頁 共<strong>'+pagecount+'</strong>頁 共<strong>' + total + '</strong>條記錄 </span>';
	if(curpage==1){
		pagediv = pagediv + '<span class="hidden wd">第一頁</span>';
		pagediv = pagediv + '<span class="hidden wd">上一頁</span>';
	}else{
		pagediv = pagediv + '<span class="wd"><a href="' + url + '&page=1">第一頁</a></span>';		
		pagediv = pagediv + '<span class="wd"><a href="' + url + '&page=' + (curpage-1)+'">上一頁</a></span>';
	}

	if(curpage==pagecount){
		pagediv = pagediv + '<span class="hidden wd">下一頁</span>';
		pagediv = pagediv + '<span class="hidden wd">最後一頁</span>';
	}else{
		pagediv = pagediv + '<span class="wd"><a href="' + url + '&page=' + (curpage+1)+'">下一頁</a></span>';
		pagediv = pagediv + '<span class="wd"><a href="' + url + '&page=' + pagecount+'">最後一頁</a></span>';
	}
	$("#"+div).html(pagediv);
}

function print_r (array, return_val) {
    // Prints out or returns information about the specified variable  
    // 
    // version: 1103.1210
    // discuss at: http://phpjs.org/functions/print_r    // +   original by: Michael White (http://getsprink.com)
    // +   improved by: Ben Bryan
    // +      input by: Brett Zamir (http://brett-zamir.me)
    // +      improved by: Brett Zamir (http://brett-zamir.me)
    // +   improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)    // -    depends on: echo
    // *     example 1: print_r(1, true);
    // *     returns 1: 1
    var output = "",
        pad_char = " ",        pad_val = 4,
        d = this.window.document;
    var getFuncName = function (fn) {
        var name = (/\W*function\s+([\w\$]+)\s*\(/).exec(fn);
        if (!name) {            return '(Anonymous)';
        }
        return name[1];
    };
     var repeat_char = function (len, pad_char) {
        var str = "";
        for (var i = 0; i < len; i++) {
            str += pad_char;
        }        return str;
    };
 
    var formatArray = function (obj, cur_depth, pad_val, pad_char) {
        if (cur_depth > 0) {            cur_depth++;
        }
 
        var base_pad = repeat_char(pad_val * cur_depth, pad_char);
        var thick_pad = repeat_char(pad_val * (cur_depth + 1), pad_char);        var str = "";
 
        if (typeof obj === 'object' && obj !== null && obj.constructor && getFuncName(obj.constructor) !== 'PHPJS_Resource') {
            str += "Array\n" + base_pad + "(\n";
            for (var key in obj) {                if (obj[key] instanceof Array) {
                    str += thick_pad + "[" + key + "] => " + formatArray(obj[key], cur_depth + 1, pad_val, pad_char);
                } else {
                    str += thick_pad + "[" + key + "] => " + obj[key] + "\n";
                }            }
            str += base_pad + ")\n";
        } else if (obj === null || obj === undefined) {
            str = '';
        } else { // for our "resource" class            str = obj.toString();
        }
 
        return str;
    }; 
    output = formatArray(array, 0, pad_val, pad_char);
 
    if (return_val !== true) {
        if (d.body) {            this.echo(output);
        } else {
            try {
                d = XULDocument; // We're in XUL, so appending as plain text won't work; trigger an error out of XUL
                this.echo('<pre xmlns="http://www.w3.org/1999/xhtml" style="white-space:pre;">' + output + '</pre>');            } catch (e) {
                this.echo(output); // Outputting as plain text may work in some plain XML
            }
        }
        return true;    } else {
        return output;
    }
}

/* 內容滾動條 */
function bindSilder(contentId,barId){
	
	var barHeight=30;
	var barWidth=8;

	var contentObj=$("#"+contentId);
	var barObj=$("#"+barId);
	
	if(!contentObj.length || !barObj.length) return;
	
	contentObj.html("<div id='"+contentId+"_sub'>"+contentObj.html()+"</div>");
	var subContentObj=$("#"+contentId+"_sub");
	
	var contentObj_H=contentObj.height();
	var subContentObj_H=subContentObj.height();
	if(parseInt(contentObj[0].scrollHeight)>parseInt(subContentObj_H)){
		subContentObj_H=parseInt(contentObj[0].scrollHeight);
	}
 
	if(contentObj_H>=subContentObj_H){
	
		barObj.html("");
		return false;
	}
	
	var scrollTopH=subContentObj_H-contentObj_H;
	barObj.height(contentObj_H);
	
	var barStr='<div id="'+barId+'_bar" style="width:'+barWidth+'px; height:'+barHeight+'px; background:#000000; position:relative; top:0px; left:0px;z-index:10;cursor:pointer"></div>';
	barStr+='<div style="width:1px; height:'+(contentObj_H-3)+'px; margin-left:4px;position:relative; top:-'+barHeight+'px; background:#000000;z-index:9"></div>';
	
	barObj.html(barStr);
	
 
	var drapBarObj=$("#"+barId+"_bar")

	var barP=0;
	drapBarObj.mousedown(function(){
	  barP=drapBarObj.css("top");
	  barP=parseInt(barP.replace("px",''));
	});
 
	drapBarObj.drag(function( ev, dd ){
		var m=barP+dd.deltaY;
		if(m>=0 && m<=contentObj_H-barHeight){
			$(this).css({
				top:m
			});  
			contentObj.scrollTop((m)/(contentObj_H-barHeight)*scrollTopH);
			
			
		}else if(m<0){
			$(this).css({
				top:0
			});  
			contentObj.scrollTop(0);
			
		}else if(m<contentObj_H-barHeight){
			$(this).css({
				top:contentObj_H-barHeight
			});  
			contentObj.scrollTop(contentObj_H-barHeight);
			
		}
   });
 
   contentObj.scroll(function(){
console.info(contentObj.scrollTop()/scrollTopH*(contentObj_H-barHeight))  ; 
		drapBarObj.css({
			 top:contentObj.scrollTop()/scrollTopH*(contentObj_H-barHeight)
		});
	});
   
	var scrollStartPos=0;
	var scrollTop=0;
	
	if(is_apple==2){
		contentObj.css({overflow: 'auto'});
	}
	
	if(is_apple==1){
		contentObj[0].addEventListener("touchstart", function(event) {
			scrollStartPos=parseInt(event.touches[0].pageY);
			scrollTop=parseInt(contentObj.scrollTop());
			event.preventDefault();
		},false);
		
		contentObj[0].addEventListener("touchmove", function(event) {
			$("#txt").html(scrollTop+"="+scrollStartPos+"=="+event.touches[0].pageY);
			if(scrollStartPos<event.touches[0].pageY){
				contentObj.scrollTop(scrollTop+(event.touches[0].pageY-scrollStartPos));
			}else{
				contentObj.scrollTop(scrollTop-(scrollStartPos-event.touches[0].pageY));
			}
			event.preventDefault();
		},false);
	}
}

	function showLBG(ct,n){
		var sh=$(document).height();
		var sw=$(document).width();
		var ch=$(window).height();
		var cw=$(window).width();
		var st=$(window).scrollTop();
		var sl=$(window).scrollLeft();
		var objH=$("#"+ct).height();
		var objW=$("#"+ct).width();
		var tbT=(Number(st)+(Number(ch)-Number(objH))/3)+"px";
		var tbL=(Number(sl)+(Number(cw)-Number(objW))/2)+"px";
		if(n==0){
			$("#fullbg").css({width:sw,height:sh});
			//$("#"+ct).css({top:tbT});
			$("#"+ct).css({top:"150px"});
			$("#fullbg").fadeTo('slow', 0.01);
			$("#"+ct).fadeIn('slow');
			//$(window).scroll(function(){showLB(ct,1)});
			//$(window).resize(function(){showLB(ct,1)});
		}else{
			if($("#fullbg").css("display")=="block"){
				$("#fullbg").css({width:sw,height:sh});
				$("#"+ct).css({top:tbT});
			}
		}
	}

	function closeLBG(){
		$("#dialoga").fadeOut('slow');	
		$("#fullbg").fadeOut('slow');		
	}